package com.mnsq.subject.service.impl;

import com.mnsq.common.bean.entity.subject.Subject;
import com.mnsq.common.dao.SubjectRepository;
import com.mnsq.common.tools.jpa.JpaExample;
import com.mnsq.subject.bean.condition.SubjectCondition;
import com.mnsq.subject.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author Administrator
 * @date 2019/3/17 0017
 */
@Service
public class SubjectServiceImpl implements SubjectService {
    @Autowired
    private SubjectRepository subjectRepository;

    @Override
    public Subject queryByUnique(String unique) {
        SubjectCondition sc = new SubjectCondition();
        sc.setStatus(null);
        sc.setUnique(unique);
        Optional<Subject> one = subjectRepository.findOne(JpaExample.getInstance().getExample(sc, sc.getInstance()));
        return one.get();
    }
}
